//
//  FunctionServiceHeadVC.m
//  BusinessMarket
//
//  Created by Michael Li on 2018/12/4.
//  Copyright © 2018年 Michael Li. All rights reserved.
//

#import "FunctionServiceHeadVC.h"
#import "MenuView.h"
#import "ReleaseModel.h"
#import "HomeModel.h"
@interface FunctionServiceHeadVC()
@property(nonatomic,strong) MenuView *menuView;
@property(nonatomic,strong) AFHTTPSessionManager *manager;
@property(nonatomic,strong) NSString *urlString;
@property(nonatomic,strong) NSDictionary  *dict;
@property(nonatomic,assign) CGFloat w;
@property(nonatomic,strong) NSMutableArray *industryMuta;
@end
@implementation FunctionServiceHeadVC
-(NSMutableArray *)industryMuta
{
    if (!_industryMuta) {
        _industryMuta = [NSMutableArray array];
    }
    return _industryMuta;
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        self.manager = [AFHTTPSessionManager manager];
        [self reloadInternetData];
        
    }
    return self;
}
-(void)reloadInternetData
{
    

    self.urlString = [NSString stringWithFormat:@"%@/industry/list",kUrl];
    self.dict = nil;
    [self.manager POST:self.urlString parameters:self.dict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSArray *date = [responseObject objectForKey:@"date"];
        
        for (NSDictionary *dict in date) {
            HomeModel *model = [HomeModel mj_objectWithKeyValues:dict];
            [self.industryMuta addObject:model];
        }
        
        XLog(@"self.industryMuta:%@",self.industryMuta);
        [self setUpUI];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        XLog(@"error:%@",error);
    }];
    

}
-(void)setUpUI
{
    NSArray *temp = @[@"行业",@"类型",@"地区",@"排序"];
//    self.index = 0;
    self.w = 60;
//    self.titleScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kWidth, 40)];
//
//    [self addSubview:self.titleScrollView];
    
//    self.showBtn = [[UIButton alloc]initWithFrame:CGRectMake(kWidth-40, 0, 40, 40)];
//    self.showBtn.backgroundColor = kOrangeBg;
//    [self addSubview:self.showBtn];
//    [self.showBtn setTitle:@"→" forState:UIControlStateNormal];
//    [self.showBtn addTarget:self action:@selector(clickShowBtn) forControlEvents:UIControlEventTouchUpInside];
    
    CGRect frame = CGRectMake(0.f,0, kWidth, 50);
    self.menuView = [[MenuView alloc] initWithFrame:frame];
    self.menuView.searchIndex = 1;
    XLog(@"%ld",self.kNavHeight);
//    self.menuView.navigationHeight = self.kNavHeight+60;
    //    self.menu.backgroundColor = kOrangeBg;
    self.menuView.navigationHeight = self.kNavHeight+55;
    [self addSubview:self.menuView];
    // 阴影颜色
    self.menuView.layer.shadowColor = kLineColor.CGColor;
    // 阴影偏移，默认(0, -3)
    self.menuView.layer.shadowOffset = CGSizeMake(0,4);
    // 阴影透明度，默认0
    self.menuView.layer.shadowOpacity = 0.5;
    // 阴影半径，默认3
    self.menuView.layer.shadowRadius = 10;
    //    self.menu.dataSource =self.dataSourceOne;
    self.menuView.titles = temp;
    self.menuView.oneArray = self.industryMuta;
    
    NSArray *twoArray = @[@{@"content":@"不限"},@{@"content":@"个人提供"},@{@"content":@"企业提供"}];
    self.industryMuta = nil;
    for (NSDictionary *dict in twoArray) {
        HomeModel *model = [HomeModel mj_objectWithKeyValues:dict];
        [self.industryMuta addObject:model];
    }
    self.menuView.twoArray = self.industryMuta;
    XLog(@"self.menuView.twoArray:%@",self.menuView.twoArray);
    NSArray *threeArray = @[@{@"content":@"全国不限"},@{@"content":@"常用地区"},@{@"content":@"省/直辖市"}];
    self.industryMuta = nil;
    for (NSDictionary *dict in threeArray) {
        HomeModel *model = [HomeModel mj_objectWithKeyValues:dict];
        [self.industryMuta addObject:model];
    }
    self.menuView.threeArray = self.industryMuta;
    NSArray *fourArray = @[@{@"content":@"更新时间"},@{@"content":@"评价分数"},@{@"content":@"评论数量"}];
    self.industryMuta = nil;
    for (NSDictionary *dict in fourArray) {
        HomeModel *model = [HomeModel mj_objectWithKeyValues:dict];
        [self.industryMuta addObject:model];
    }
    self.menuView.fourArray = self.industryMuta;
    
}

@end
